﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using myTunes.API;

namespace myTunes.Commands
{
    public class ShowHideITunesCommand : ICommand
    {
        private iTunesPlayer _player;

        public ShowHideITunesCommand(iTunesPlayer player)
        {
            _player = player;
        }

        #region ICommand Members

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            IntPtr h = User32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "iTunes", IntPtr.Zero);

            if (User32.IsWindowVisible(h))
            {
                User32.ShowWindow(h, User32.WindowStatus.SW_HIDE);
            }
            else
            {
                User32.ShowWindow(h, User32.WindowStatus.SW_SHOW);
                User32.MakeNormal(h);
            }
        }

        #endregion
    }
}
